package com.zhou.util;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;

import android.util.Log;

public class ZhouHttpPostHelper {
	private static String host = "http://192.168.0.105:8080/Pocket";
	public static boolean commit(String servletName, List<NameValuePair> params)
			throws ClientProtocolException, IOException {
		String url = host+"/" +servletName;
		HttpPost httpPost = new HttpPost(url);
		httpPost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
		Log.i("url", url);
		HttpResponse response = new DefaultHttpClient().execute(httpPost);
		if (response.getStatusLine().getStatusCode()==200) {
			return true;
		}
		else if (response.getStatusLine().getStatusCode()==1110) {
			return true;
		} 
			
		
		else {
			return false;
		}
		
	}
	
	
	
	
}
